package com.management.controller;


import com.management.controller.form.*;
import com.management.service.AccountRoleProjectService;
import com.management.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 龙世超
 * @since 2022-03-24
 */
@Api(tags = "用户角色项目相关")
@RestController
@RequestMapping("/accountRoleProject")
public class AccountRoleProjectController {
    @Resource
    private AccountRoleProjectService accountRoleProjectService;

    /**
     * 给人员分配某个项目的某个职位
     * @param addProjectRoleForm 成员id项目id角色id
     * @return
     */
    @ApiOperation("给人员分配某个项目的某个职位")
    @GetMapping("addProjectRole")
    public Result addProjectRole(AddProjectRoleForm addProjectRoleForm){
       Result result= accountRoleProjectService.addProjectRole(addProjectRoleForm);
        return result;
    }

    /**
     * 获取所有人员在所有项目担任角色情况
     * @param memberPageForm 分页参数
     * @return
     */
    @ApiOperation("获取所有人员在所有项目担任角色情况")
    @PostMapping("/getMemberByPage")
    public Result getMemberByPage(@RequestBody MemberPageForm memberPageForm){
       Result result= accountRoleProjectService.getAllMember(memberPageForm);
        return result;
    }

    /**
     * 获取某个项目所有成员
     * @return
     */
    @ApiOperation("获取某个项目所有成员")
    @GetMapping("getProjectAccount")
    public Result getProjectAccount(ProjectAccountForm projectAccountForm){
       Result result= accountRoleProjectService.findAccountByProject(projectAccountForm);
    return result;
    }

    /**
     * 移除某个项目的某个人员的角色
     * @param delAccountForm
     * @return
     */
    @ApiOperation("移除某个项目的某个人员的角色")
    @PostMapping("delAccount")
    public Result delAccount(@RequestBody DelAccountForm delAccountForm){
       Result result= accountRoleProjectService.delAccount(delAccountForm);
        return result;
    }

    /**
     * 获取所有我参与的项目
     * @param getMyProjectForm
     * @return
     */
    @ApiOperation("获取所有我参与的项目")
    @GetMapping("getMyProject")
    public Result getMyProject(GetMyProjectForm getMyProjectForm){
       Result result= accountRoleProjectService.getMyProject(getMyProjectForm);
       return result;
    }
}

